<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Random - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">base
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-bytes">::bytes</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-new_seed">::new_seed</a>
    <li ><a href="#method-c-rand">::rand</a>
    <li ><a href="#method-c-seed">::seed</a>
    <li ><a href="#method-c-srand">::srand</a>
    <li ><a href="#method-c-urandom">::urandom</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-bytes">#bytes</a>
    <li ><a href="#method-i-rand">#rand</a>
    <li ><a href="#method-i-seed">#seed</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Random">
    <h1 id="class-Random" class="class">
      class Random
    </h1>

    <section class="description">
    
<p><a href="Random.html"><code>Random</code></a> provides an interface to Ruby’s pseudo-random number generator, or PRNG.  The PRNG produces a deterministic sequence of bits which approximate true randomness. The sequence may be represented by integers, floats, or binary strings.</p>

<p>The generator may be initialized with either a system-generated or user-supplied seed value by using <a href="Random.html#method-c-srand"><code>Random.srand</code></a>.</p>

<p>The class method <a href="Random.html#method-c-rand"><code>Random.rand</code></a> provides the base functionality of <a href="Kernel.html#method-i-rand"><code>Kernel.rand</code></a> along with better handling of floating point values. These are both interfaces to the Ruby system PRNG.</p>

<p><a href="Random.html#method-c-new"><code>Random.new</code></a> will create a new PRNG with a state independent of the Ruby system PRNG, allowing multiple generators with different seed values or sequence positions to exist simultaneously. <a href="Random.html"><code>Random</code></a> objects can be marshaled, allowing sequences to be saved and resumed.</p>

<p>PRNGs are currently implemented as a modified Mersenne Twister with a period of 2**19937-1.  As this algorithm is <em>not</em> for cryptographical use, you must use SecureRandom for security purpose, instead of this PRNG.</p>

<p>See also <a href="Random/Formatter.html"><code>Random::Formatter</code></a> module that adds convenience methods to generate various forms of random data.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-bytes" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          bytes(size) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a random binary string. The argument <code>size</code> specifies the length of the returned string.</p>

                              <div class="method-source-code" id="bytes-source">
            <pre>static VALUE
random_s_bytes(VALUE obj, VALUE len)
{
    rb_random_t *rnd = rand_start(default_rand());
    return rand_bytes(&amp;random_mt_if, rnd, NUM2LONG(rb_to_int(len)));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(seed = Random.new_seed) &rarr; prng
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new PRNG using <code>seed</code> to set the initial state. If <code>seed</code> is omitted, the generator is initialized with <a href="Random.html#method-c-new_seed"><code>Random.new_seed</code></a>.</p>

<p>See <a href="Random.html#method-c-srand"><code>Random.srand</code></a> for more information on the use of seed values.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
random_init(int argc, VALUE *argv, VALUE obj)
{
    rb_random_t *rnd = try_get_rnd(obj);
    const rb_random_interface_t *rng = rb_rand_if(obj);

    if (!rng) {
        rb_raise(rb_eTypeError, &quot;undefined random interface: %s&quot;,
                 RTYPEDDATA_TYPE(obj)-&gt;wrap_struct_name);
    }

    unsigned int major = rng-&gt;version.major;
    unsigned int minor = rng-&gt;version.minor;
    if (major != RUBY_RANDOM_INTERFACE_VERSION_MAJOR) {
        rb_raise(rb_eTypeError, &quot;Random interface version &quot;
                 STRINGIZE(RUBY_RANDOM_INTERFACE_VERSION_MAJOR) &quot;.&quot;
                 STRINGIZE(RUBY_RANDOM_INTERFACE_VERSION_MINOR) &quot; &quot;
                 &quot;expected: %d.%d&quot;, major, minor);
    }
    argc = rb_check_arity(argc, 0, 1);
    rb_check_frozen(obj);
    if (argc == 0) {
        rnd-&gt;seed = rand_init_default(rng, rnd);
    }
    else {
        rnd-&gt;seed = rand_init(rng, rnd, rb_to_int(argv[0]));
    }
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new_seed" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new_seed &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an arbitrary seed value. This is used by <a href="Random.html#method-c-new"><code>Random.new</code></a> when no seed value is specified as an argument.</p>

<pre class="ruby"><span class="ruby-constant">Random</span>.<span class="ruby-identifier">new_seed</span>  <span class="ruby-comment">#=&gt; 115032730400174366788466674494640623225</span>
</pre>

                              <div class="method-source-code" id="new_seed-source">
            <pre>static VALUE
random_seed(VALUE _)
{
    VALUE v;
    with_random_seed(DEFAULT_SEED_CNT, 1) {
        v = make_seed_value(seedbuf, DEFAULT_SEED_CNT);
    }
    return v;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rand" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand &rarr; float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand(max) &rarr; number
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand(range) &rarr; number
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns a random number using the Ruby system PRNG.</p>

<p>See also <a href="Random.html#method-i-rand"><code>Random#rand</code></a>.</p>

                              <div class="method-source-code" id="rand-source">
            <pre>static VALUE
random_s_rand(int argc, VALUE *argv, VALUE obj)
{
    VALUE v = rand_random(argc, argv, Qnil, rand_start(default_rand()));
    check_random_number(v, argv);
    return v;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-seed" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          seed &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the seed value used to initialize the Ruby system PRNG. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers.</p>

<pre class="ruby"><span class="ruby-constant">Random</span>.<span class="ruby-identifier">seed</span>      <span class="ruby-comment">#=&gt; 1234</span>
<span class="ruby-identifier">prng1</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Random</span>.<span class="ruby-identifier">seed</span>)
<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">seed</span>       <span class="ruby-comment">#=&gt; 1234</span>
<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>)  <span class="ruby-comment">#=&gt; 47</span>
<span class="ruby-constant">Random</span>.<span class="ruby-identifier">seed</span>      <span class="ruby-comment">#=&gt; 1234</span>
<span class="ruby-constant">Random</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>) <span class="ruby-comment">#=&gt; 47</span>
</pre>

                              <div class="method-source-code" id="seed-source">
            <pre>static VALUE
random_s_seed(VALUE obj)
{
    rb_random_mt_t *rnd = rand_mt_start(default_rand());
    return rnd-&gt;base.seed;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-srand" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          srand(number = Random.new_seed) &rarr; old_seed
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Seeds the system pseudo-random number generator, with <code>number</code>. The previous seed value is returned.</p>

<p>If <code>number</code> is omitted, seeds the generator using a source of entropy provided by the operating system, if available (/dev/urandom on Unix systems or the RSA cryptographic provider on Windows), which is then combined with the time, the process id, and a sequence number.</p>

<p>srand may be used to ensure repeatable sequences of pseudo-random numbers between different runs of the program. By setting the seed to a known value, programs can be made deterministic during testing.</p>

<pre class="ruby"><span class="ruby-identifier">srand</span> <span class="ruby-value">1234</span>               <span class="ruby-comment"># =&gt; 268519324636777531569100071560086917274</span>
[ <span class="ruby-identifier">rand</span>, <span class="ruby-identifier">rand</span> ]           <span class="ruby-comment"># =&gt; [0.1915194503788923, 0.6221087710398319]</span>
[ <span class="ruby-identifier">rand</span>(<span class="ruby-value">10</span>), <span class="ruby-identifier">rand</span>(<span class="ruby-value">1000</span>) ] <span class="ruby-comment"># =&gt; [4, 664]</span>
<span class="ruby-identifier">srand</span> <span class="ruby-value">1234</span>               <span class="ruby-comment"># =&gt; 1234</span>
[ <span class="ruby-identifier">rand</span>, <span class="ruby-identifier">rand</span> ]           <span class="ruby-comment"># =&gt; [0.1915194503788923, 0.6221087710398319]</span>
</pre>

                              <div class="method-source-code" id="srand-source">
            <pre>static VALUE
rb_f_srand(int argc, VALUE *argv, VALUE obj)
{
    VALUE seed, old;
    rb_random_mt_t *r = rand_mt_start(default_rand());

    if (rb_check_arity(argc, 0, 1) == 0) {
        seed = random_seed(obj);
    }
    else {
        seed = rb_to_int(argv[0]);
    }
    old = r-&gt;base.seed;
    rand_init(&amp;random_mt_if, &amp;r-&gt;base, seed);
    r-&gt;base.seed = seed;

    return old;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-urandom" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          urandom(size) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string, using platform providing features. Returned value is expected to be a cryptographically secure pseudo-random number in binary form. This method raises a <a href="RuntimeError.html"><code>RuntimeError</code></a> if the feature provided by platform failed to prepare the result.</p>

<p>In 2017, Linux manpage random(7) writes that “no cryptographic primitive available today can hope to promise more than 256 bits of security”.  So it might be questionable to pass size &gt; 32 to this method.</p>

<pre class="ruby"><span class="ruby-constant">Random</span>.<span class="ruby-identifier">urandom</span>(<span class="ruby-value">8</span>)  <span class="ruby-comment">#=&gt; &quot;\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA&quot;</span>
</pre>

                              <div class="method-source-code" id="urandom-source">
            <pre>static VALUE
random_raw_seed(VALUE self, VALUE size)
{
    long n = NUM2ULONG(size);
    VALUE buf = rb_str_new(0, n);
    if (n == 0) return buf;
    if (fill_random_bytes(RSTRING_PTR(buf), n, TRUE))
        rb_raise(rb_eRuntimeError, &quot;failed to get urandom&quot;);
    return buf;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prng1 == prng2 &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if the two generators have the same internal state, otherwise false.  Equivalent generators will return the same sequence of pseudo-random numbers.  Two generators will generally have the same state only if they were initialized with the same seed</p>

<pre class="ruby"><span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>             <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1234</span>) <span class="ruby-operator">==</span> <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1234</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>and have the same invocation history.</p>

<pre class="ruby"><span class="ruby-identifier">prng1</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1234</span>)
<span class="ruby-identifier">prng2</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1234</span>)
<span class="ruby-identifier">prng1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">prng2</span> <span class="ruby-comment"># =&gt; true</span>

<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">rand</span>     <span class="ruby-comment"># =&gt; 0.1915194503788923</span>
<span class="ruby-identifier">prng1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">prng2</span> <span class="ruby-comment"># =&gt; false</span>

<span class="ruby-identifier">prng2</span>.<span class="ruby-identifier">rand</span>     <span class="ruby-comment"># =&gt; 0.1915194503788923</span>
<span class="ruby-identifier">prng1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">prng2</span> <span class="ruby-comment"># =&gt; true</span>
</pre>

                              <div class="method-source-code" id="3D-3D-source">
            <pre>static VALUE
rand_mt_equal(VALUE self, VALUE other)
{
    rb_random_mt_t *r1, *r2;
    if (rb_obj_class(self) != rb_obj_class(other)) return Qfalse;
    r1 = get_rnd_mt(self);
    r2 = get_rnd_mt(other);
    if (memcmp(r1-&gt;mt.state, r2-&gt;mt.state, sizeof(r1-&gt;mt.state))) return Qfalse;
    if ((r1-&gt;mt.next - r1-&gt;mt.state) != (r2-&gt;mt.next - r2-&gt;mt.state)) return Qfalse;
    if (r1-&gt;mt.left != r2-&gt;mt.left) return Qfalse;
    return rb_equal(r1-&gt;base.seed, r2-&gt;base.seed);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-bytes" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          bytes(size) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a random binary string containing <code>size</code> bytes.</p>

<pre class="ruby"><span class="ruby-identifier">random_string</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">bytes</span>(<span class="ruby-value">10</span>) <span class="ruby-comment"># =&gt; &quot;\xD7:R\xAB?\x83\xCE\xFAkO&quot;</span>
<span class="ruby-identifier">random_string</span>.<span class="ruby-identifier">size</span>                   <span class="ruby-comment"># =&gt; 10</span>
</pre>

                              <div class="method-source-code" id="bytes-source">
            <pre>static VALUE
random_bytes(VALUE obj, VALUE len)
{
    rb_random_t *rnd = try_get_rnd(obj);
    return rand_bytes(rb_rand_if(obj), rnd, NUM2LONG(rb_to_int(len)));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-rand" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand &rarr; float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand(max) &rarr; number
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand(range) &rarr; number
                              </span>
                            </div>

                            <div class="method-description">
                              <p>When <code>max</code> is an <a href="Integer.html"><code>Integer</code></a>, <code>rand</code> returns a random integer greater than or equal to zero and less than <code>max</code>. Unlike <a href="Kernel.html#method-i-rand"><code>Kernel.rand</code></a>, when <code>max</code> is a negative integer or zero, <code>rand</code> raises an <a href="ArgumentError.html"><code>ArgumentError</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">prng</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>)       <span class="ruby-comment"># =&gt; 42</span>
</pre>

<p>When <code>max</code> is a <a href="Float.html"><code>Float</code></a>, <code>rand</code> returns a random floating point number between 0.0 and <code>max</code>, including 0.0 and excluding <code>max</code>.</p>

<pre class="ruby"><span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">1.5</span>)       <span class="ruby-comment"># =&gt; 1.4600282860034115</span>
</pre>

<p>When <code>range</code> is a <a href="Range.html"><code>Range</code></a>, <code>rand</code> returns a random number where <code>range.member?(number) == true</code>.</p>

<pre class="ruby"><span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">5</span><span class="ruby-operator">..</span><span class="ruby-value">9</span>)      <span class="ruby-comment"># =&gt; one of [5, 6, 7, 8, 9]</span>
<span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">5</span><span class="ruby-operator">...</span><span class="ruby-value">9</span>)     <span class="ruby-comment"># =&gt; one of [5, 6, 7, 8]</span>
<span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">5.0</span><span class="ruby-operator">..</span><span class="ruby-value">9.0</span>)  <span class="ruby-comment"># =&gt; between 5.0 and 9.0, including 9.0</span>
<span class="ruby-identifier">prng</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">5.0</span><span class="ruby-operator">...</span><span class="ruby-value">9.0</span>) <span class="ruby-comment"># =&gt; between 5.0 and 9.0, excluding 9.0</span>
</pre>

<p>Both the beginning and ending values of the range must respond to subtract (<code>-</code>) and add (<code>+</code>)methods, or rand will raise an <a href="ArgumentError.html"><code>ArgumentError</code></a>.</p>

                              <div class="method-source-code" id="rand-source">
            <pre>static VALUE
random_rand(int argc, VALUE *argv, VALUE obj)
{
    VALUE v = rand_random(argc, argv, obj, try_get_rnd(obj));
    check_random_number(v, argv);
    return v;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-seed" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          seed &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the seed value used to initialize the generator. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers.</p>

<pre class="ruby"><span class="ruby-identifier">prng1</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1234</span>)
<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">seed</span>       <span class="ruby-comment">#=&gt; 1234</span>
<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>)  <span class="ruby-comment">#=&gt; 47</span>

<span class="ruby-identifier">prng2</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">prng1</span>.<span class="ruby-identifier">seed</span>)
<span class="ruby-identifier">prng2</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>)  <span class="ruby-comment">#=&gt; 47</span>
</pre>

                              <div class="method-source-code" id="seed-source">
            <pre>static VALUE
random_get_seed(VALUE obj)
{
    return get_rnd(obj)-&gt;seed;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

